package com.psc.model.a;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.converter.PropertyConverter;

import java.util.List;

/**
 * Creator:Yx
 * Time:2020/7/25 13:40
 * Description:0/1/3图模型 大家都在看
 */
public class AllWatchingModeBean {
    private String id;
    private String title;

    private List<AllWatchingMode> hotReadings;

    public class AllWatchingMode {
        private String id;//": 151,
        private String hot;//热度
        private String[] image;//图片
        private String label;//标签
        private String numberOfComment;//评论数
        private String numberOfRead;//阅读
        private String title;//标题
        private String date;//时间

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getHot() {
            return hot;
        }

        public void setHot(String hot) {
            this.hot = hot;
        }

        public String[] getImage() {
            return image;
        }

        public void setImage(String[] image) {
            this.image = image;
        }

        public String getLabel() {
            return label;
        }

        public void setLabel(String label) {
            this.label = label;
        }

        public String getNumberOfComment() {
            return numberOfComment;
        }

        public void setNumberOfComment(String numberOfComment) {
            this.numberOfComment = numberOfComment;
        }

        public String getNumberOfRead() {
            return numberOfRead;
        }

        public void setNumberOfRead(String numberOfRead) {
            this.numberOfRead = numberOfRead;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getDate() {
            return date;
        }

        public void setDate(String date) {
            this.date = date;
        }
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<AllWatchingMode> getHotReadings() {
        return hotReadings;
    }

    public void setHotReadings(List<AllWatchingMode> hotReadings) {
        this.hotReadings = hotReadings;
    }


    public class AllWatchingList_Converter implements PropertyConverter<List<AllWatchingMode>, String> {
        @Override
        public List<AllWatchingMode> convertToEntityProperty(String databaseValue) {
            if (databaseValue == null) {
                return null;
            }
            // 先得获得这个，然后再typeToken.getType()，否则会异常
            TypeToken<List<AllWatchingMode>> typeToken = new TypeToken<List<AllWatchingMode>>() {
            };
            return new Gson().fromJson(databaseValue, typeToken.getType());
        }

        @Override
        public String convertToDatabaseValue(List<AllWatchingMode> arrays) {
            if (arrays == null || arrays.size() == 0) {
                return null;
            } else {
                String sb = new Gson().toJson(arrays);
                return sb;

            }
        }
    }


}
